package cn.tedu.file;

import java.io.*;

/*字符输出流*/
public class TestOut2 {
    public static void main(String[] args) {
        //method1();
        method2();
    }

    private static void method2() {
        BufferedWriter w=null;
        try {
//            w=new BufferedWriter(new FileWriter(new File("D:\\ready\\1.txt")));
//            w=new BufferedWriter(new FileWriter("D:\\ready\\1.txt"));
            w=new BufferedWriter(new FileWriter(new File("D:\\ready\\1.txt"),true));
            w=new BufferedWriter(new FileWriter("D:\\ready\\1.txt",true));

            w.write(100);
            w.write(100);
            w.write(100);
            w.write(100);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                w.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void method1() {
        Writer w=null;
        try{
            //w=new FileWriter(new File("D:\\ready\\1.txt"));
           // w=new FileWriter("D:\\ready\\1.txt");
            w=new FileWriter(new File("D:\\ready\\1.txt"),true);
            w=new FileWriter("D:\\ready\\1.txt",true);

            w.write(99);
            w.write(99);
            w.write(99);
            w.write(99);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try {
                w.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
